package 浅拷贝;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-02
 * Time: 0:59
 */
class Money{
    public double money = 52.0;
}
class Person implements Cloneable{
    public int age = 10;
    public Money money = new Money();
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }
}

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person();
        Person person1 = (Person) person.clone();
        System.out.println(person);
        System.out.println(person1);
        System.out.println("================");
        System.out.println(person.money.money);
        System.out.println(person1.money.money);
        System.out.println("=========修改后=========");
        person1.money.money = 100.0;
        System.out.println(person.money.money);
        System.out.println(person1.money.money);
    }



}
